package com.yellowpage.bigdata.service;

import com.yellowpage.bigdata.dao.NspOnofflogTaImeiDayEntityDao;
import com.yellowpage.bigdata.data.NspOnofflogTaImeiDayEntity;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import java.util.List;
import java.util.Map;

public class NspOnofflogTaImeiDayEntityServiceImpl extends BaseServiceImpl implements NspOnofflogTaImeiDayEntityService {
	  private NspOnofflogTaImeiDayEntityDao nspOnofflogTaImeiDayEntityDao;
	
	  public void setNspOnofflogTaImeiDayEntityDao(NspOnofflogTaImeiDayEntityDao nspOnofflogTaImeiDayEntityDao) {
		  this.nspOnofflogTaImeiDayEntityDao = nspOnofflogTaImeiDayEntityDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public NspOnofflogTaImeiDayEntity getNspOnofflogTaImeiDayEntity(Long id){
	      return nspOnofflogTaImeiDayEntityDao.get(id);
	  }
	  
    public List<NspOnofflogTaImeiDayEntity> getAllNspOnofflogTaImeiDayEntity(){
        return nspOnofflogTaImeiDayEntityDao.getAll();
    }
    
    public List<Map> queryNspOnofflogTaImeiDayEntityByPage(Map queryMap, PageRender pageRender) {
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.LOG_DATE , a.OPT , a.CHANNELNO , a.IMEI_DAY_COUNT , a.IMEI_ALL_COUNT , a.IMEI_NEW_COUNT , a.VERSION  ,  "
						+ "(select b.NAME from OMC_DIC_TABLE b where b.VALUE = a.CHANNELNO and b.DIC_NAME='NSP_ONOFFLOG_CHANNEL_NO') as CHANNEL_NO_NAME  "
						+ "FROM NSP_ONOFFLOG_TA_IMEI_DAY a WHERE 1 = 1")
				.addCondition(" and LOG_DATE >= :query_logDate ")
				.addCondition(" and a.LOG_DATE <= :query_logDate_end ")
				.addCondition(" and OPT = :query_opt ")
				.addCondition(" and CHANNELNO = :query_channelno ")
				.addCondition(" and VERSION = :query_version ")
				;
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveNspOnofflogTaImeiDayEntity(NspOnofflogTaImeiDayEntity nspOnofflogTaImeiDayEntity){
        nspOnofflogTaImeiDayEntityDao.save(nspOnofflogTaImeiDayEntity);
    }
    
	  public void updateNspOnofflogTaImeiDayEntity(NspOnofflogTaImeiDayEntity nspOnofflogTaImeiDayEntity){
	      nspOnofflogTaImeiDayEntityDao.update(nspOnofflogTaImeiDayEntity);
	  }
	  
	  public void delete(List deleteList){
	      nspOnofflogTaImeiDayEntityDao.remove(deleteList);
	  }


	public List<Map> queryAllNspOnofflogTaImeiDayEntity(Map queryMap) {
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.LOG_DATE , a.OPT , a.CHANNELNO , a.IMEI_DAY_COUNT , a.IMEI_ALL_COUNT , a.IMEI_NEW_COUNT , a.VERSION ,  "
						+ "(select b.NAME from OMC_DIC_TABLE b where b.VALUE = a.CHANNELNO and b.DIC_NAME='NSP_ONOFFLOG_CHANNEL_NO') as CHANNEL_NO_NAME  "
						+ "FROM NSP_ONOFFLOG_TA_IMEI_DAY a WHERE 1 = 1")
				.addCondition(" and LOG_DATE >= :query_logDate ")
				.addCondition(" and a.LOG_DATE <= :query_logDate_end ")
				.addCondition(" and OPT = :query_opt ")
				.addCondition(" and CHANNELNO = :query_channelno ")
				.addCondition(" and VERSION = :query_version ")
				;

		List<Map> resultList = sqlAssistant.query(baseDao.getConnection(), queryMap);
		return resultList;
	}


}	